import 'package:flutterstudyapplast/business/viewmodels/article_collect_viwemodel.dart';
import 'package:flutterstudyapplast/business/viewmodels/article_viewmodel.dart';
import 'package:flutterstudyapplast/business/viewmodels/user_viewmodel.dart';
import 'package:flutterstudyapplast/services/user/user_service.dart';
import 'package:flutterstudyapplast/services/user/user_service_implementation.dart';
import 'package:get_it/get_it.dart';

import 'api/api.dart';
import 'api/api_implementation.dart';
import 'article/article_service.dart';
import 'article/article_service_implementation.dart';
import 'articlecollect/article_collect_service.dart';
import 'articlecollect/article_collect_service_implementation.dart';

///注册service viewmodel 供全局使用
GetIt serviceLocator = GetIt.instance;

void setUpServiceLocator(){
  ///service
  serviceLocator.registerLazySingleton<Api>(()=>ApiImpl());
  serviceLocator.registerLazySingleton<ArticleService>(()=>ArticleServiceImpl());
  serviceLocator.registerLazySingleton<ArticleCollectService>(()=>ArticleCollcetSericeImpl());
  serviceLocator.registerLazySingleton<UserService>(()=>UserServiceImpl());

  ///viwemodel
  serviceLocator.registerFactory<ArticleViewModel>(()=>ArticleViewModel());
  serviceLocator.registerFactory<ArticleCollectViewModel>(()=>ArticleCollectViewModel());
  serviceLocator.registerFactory<UserViewModel>(()=>UserViewModel());
}
